package com.ruoyi.web.controller.pollution;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pollution.domain.BusPsMidWaterhourdata;
import com.ruoyi.pollution.service.IBusPsMidWaterhourdataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 小时污染物监测数据Controller
 * 
 * @author ruoyi
 * @date 2025-09-18
 */
@RestController
@RequestMapping("/pollution/waterhourdata")
public class BusPsMidWaterhourdataController extends BaseController
{
    @Autowired
    private IBusPsMidWaterhourdataService busPsMidWaterhourdataService;

    /**
     * 查询小时污染物监测数据列表
     */
    //@PreAuthorize("@ss.hasPermi('pollution:waterhourdata:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusPsMidWaterhourdata busPsMidWaterhourdata)
    {
        startPage();
        List<BusPsMidWaterhourdata> list = busPsMidWaterhourdataService.selectBusPsMidWaterhourdataList(busPsMidWaterhourdata);
        return getDataTable(list);
    }

    @GetMapping("/onlineMonitorList")
    public AjaxResult onlineMonitorList(String id,String pid,String startTime,String endTime){

        return AjaxResult.success(busPsMidWaterhourdataService.onlineMonitorList(id,pid,startTime,endTime));
    }
    /**
     * 导出小时污染物监测数据列表
     */
    //@PreAuthorize("@ss.hasPermi('pollution:waterhourdata:export')")
    @Log(title = "小时污染物监测数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusPsMidWaterhourdata busPsMidWaterhourdata)
    {
        List<BusPsMidWaterhourdata> list = busPsMidWaterhourdataService.selectBusPsMidWaterhourdataList(busPsMidWaterhourdata);
        ExcelUtil<BusPsMidWaterhourdata> util = new ExcelUtil<BusPsMidWaterhourdata>(BusPsMidWaterhourdata.class);
        util.exportExcel(response, list, "小时污染物监测数据数据");
    }

    /**
     * 获取小时污染物监测数据详细信息
     */
    //@PreAuthorize("@ss.hasPermi('pollution:waterhourdata:query')")
    @GetMapping(value = "/{entcode}")
    public AjaxResult getInfo(@PathVariable("entcode") String entcode)
    {
        return success(busPsMidWaterhourdataService.selectBusPsMidWaterhourdataByEntcode(entcode));
    }

    /**
     * 新增小时污染物监测数据
     */
    //@PreAuthorize("@ss.hasPermi('pollution:waterhourdata:add')")
    @Log(title = "小时污染物监测数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusPsMidWaterhourdata busPsMidWaterhourdata)
    {
        return toAjax(busPsMidWaterhourdataService.insertBusPsMidWaterhourdata(busPsMidWaterhourdata));
    }

    /**
     * 修改小时污染物监测数据
     */
    //@PreAuthorize("@ss.hasPermi('pollution:waterhourdata:edit')")
    @Log(title = "小时污染物监测数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusPsMidWaterhourdata busPsMidWaterhourdata)
    {
        return toAjax(busPsMidWaterhourdataService.updateBusPsMidWaterhourdata(busPsMidWaterhourdata));
    }

    /**
     * 删除小时污染物监测数据
     */
    //@PreAuthorize("@ss.hasPermi('pollution:waterhourdata:remove')")
    @Log(title = "小时污染物监测数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{entcodes}")
    public AjaxResult remove(@PathVariable String[] entcodes)
    {
        return toAjax(busPsMidWaterhourdataService.deleteBusPsMidWaterhourdataByEntcodes(entcodes));
    }






}
